{extend name="ace/layout/master/detail" /}

{block name="title"}管理员管理{/block}
{block name="page-title"}管理员{/block}

{block name="content"}
    <input name="admin_id" class="form-control" type="hidden" value="{if $detail}{$detail->admin_id}{/if}" />
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right"> 所属用户组：</label>
        <div class="col-sm-9 roles_ary">
            <select name="role_id" class="col-xs-10 col-sm-5" required>
                <option value="0"> 请选择角色组 </option>
                {if !empty($roles)}
                    {foreach $roles as $role}
                        <option value="{$role->role_id}" {if $detail && $detail->role && $detail->role->role_id == $role->role_id}selected{/if} >{$role->role_name}</option>
                    {/foreach}
                {/if}
            </select>
        </div>
    </div>
    <div class="hr hr-dotted"></div>
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right"> 管理员名称：</label>
        <div class="col-sm-9">
            <input type="text" name="admin_name" placeholder="输入管理员名称" class="col-xs-10 col-sm-5" required="" value="{if $detail}{$detail->admin_name}{/if}" />
            <span class="lbl col-xs-12 col-sm-7">
                    <i class="icon-info-sign"></i> 唯一标识
                </span>
        </div>
    </div>
    <div class="hr hr-dotted"></div>
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right"> E-mail：</label>
        <div class="col-sm-9">
            <input type="email" name="admin_email" placeholder="输入用户邮箱" class="col-xs-10 col-sm-5" value="{if $detail}{$detail->admin_email}{/if}" />
            <span class="lbl col-xs-12 col-sm-7"><i class="icon-info-sign"></i> 用于密码找回，请认真填写</span>
        </div>
    </div>
    <div class="hr hr-dotted"></div>
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right"> 头像：</label>
        <div class="col-sm-9">
            <input type="hidden" name="admin_head">
            <div id="admin_head">
                <div id="admin_head_filePicker"><i class="icon-cloud-upload"></i></i> 选择单张图片</div>
            </div>
        </div>
    </div>
    <div class="hr hr-dotted"></div>
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right"> 登录密码：</label>
        <div class="col-sm-9">
            <input type="text" name="password" maxlength="15" minlength="6" placeholder="输入登录密码" class="col-xs-10 col-sm-5">
            <span class="lbl col-xs-12 col-sm-7">
                    <i class="icon-info-sign"></i>
                    {if $detail && $detail->password}
                    已设置密码【再次输入，则会更改；不输入，则不变动】
                    {else /}
                    <span>尚未设置密码，<b class="red">请设置密码！</b></span>
                    {/if}
            </span>
        </div>
    </div>
    <div class="hr hr-dotted"></div>
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right">
            是否启用：
            <br/>
            <small class="green"><b>启用</b></small>
            才可以登录
        </label>
        <div class="col-sm-9 radio">
            <label>
                <input name="is_check" type="radio" class="ace" value="1" {if (empty($detail) || $detail->is_check === 1) }checked{/if} />
                <span class="lbl"> 启用 </span>
            </label>
            <label>
                <input name="is_check" type="radio" class="ace" value="0" {if (empty($detail) || $detail->is_check === 0) }checked{/if} />
                <span class="lbl"> 禁用 </span>
            </label>
        </div>
    </div>
{/block}

{block name="script-src"}
{include file="ace/layout:plugins/webuploader" /}
{/block}

{block name="script"}
<script type="text/javascript">
    window.onload = function () {
        closeLayerLoading(closeAllLayer);

        // 图片上传组件
        webUploaderImgs('#admin_head_filePicker', '', '#admin_head', 'input[name=admin_head]', {'img_limit':1, 'single_graph_type':1});

        let detail = JSON.parse('{:html_get_res_from_admin($detail)}');
        if (detail && !isEmpty(detail.admin_head)){
            $('#admin_head').append(webUploaderImgHtml(detail.admin_head, 'input[name=admin_head]', $('#admin_head_filePicker').attr('span-class')));
        }
    }
</script>
{/block}